Leadtools.ImageProcessing.Effects Namespace > UserFilterCommand Class > UserFilterCommand Constructor : UserFilterCommand Constructor(Int32,Int32,LeadPoint,Int32,Int32,UserFilterCommandType,Int32[]) |
public UserFilterCommand( int filterWidth, int filterHeight, LeadPoint centerPoint, int divisor, int offset, UserFilterCommandType type, int[] matrix )
'Declaration Public Function New( _ ByVal filterWidth As Integer, _ ByVal filterHeight As Integer, _ ByVal centerPoint As LeadPoint, _ ByVal divisor As Integer, _ ByVal offset As Integer, _ ByVal type As UserFilterCommandType, _ ByVal matrix() As Integer _ )
'Usage Dim filterWidth As Integer Dim filterHeight As Integer Dim centerPoint As LeadPoint Dim divisor As Integer Dim offset As Integer Dim type As UserFilterCommandType Dim matrix() As Integer Dim instance As New UserFilterCommand(filterWidth, filterHeight, centerPoint, divisor, offset, type, matrix)
public UserFilterCommand( int filterWidth, int filterHeight, LeadPoint centerPoint, int divisor, int offset, UserFilterCommandType type, int[] matrix )
function UserFilterCommand( filterWidth , filterHeight , centerPoint , divisor , offset , type , matrix )
public: UserFilterCommand( int filterWidth, int filterHeight, LeadPoint centerPoint, int divisor, int offset, UserFilterCommandType type, array<int>^ matrix )
Public Sub UserFilterConstructorExample() Dim codecs As New RasterCodecs() codecs.ThrowExceptionsOnInvalidImages = True Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")) ' Prepare the command Dim i As Integer Dim j As Integer Dim matrix() As Integer ReDim matrix(8) ' Initialize the array with factor used to apply the high pass filter. For i = 0 To 2 For j = 0 To 2 If (j = 1 Or i = 1) Then If (j = 1 And i = 1) Then matrix(i * 3 + j) = 5 Else matrix(i * 3 + j) = -1 End If Else matrix(i * 3 + j) = 0 End If Next Next Dim command As UserFilterCommand = New UserFilterCommand(3, 3, New LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix) ' Apply the high pass custom filter. command.Run(leadImage) codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24) End Sub Public NotInheritable Class LEAD_VARS Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" End Class
public void UserFilterConstructorExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg")); // Prepare the command int [] matrix = new int[9]; // Initialize the array with factor used to apply the high pass filter. for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { if(j == 1 || i == 1) { if(j == 1 && i == 1) matrix[i * 3 + j] = 5; else matrix[i * 3 + j] = -1; } else matrix[i * 3 + j] = 0; } } UserFilterCommand command = new UserFilterCommand(3, 3, new LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix); // Apply the high pass custom filter. command.Run(image); } static class LEAD_VARS { public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; }
[TestMethod] public async Task UserFilterConstructorExample() { // Load an image RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; // Load the image string srcFileName = @"Assets\Image1.cmp"; StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); // Prepare the command int [] matrix = new int[9]; // Initialize the array with factor used to apply the high pass filter. for(int i = 0; i < 3; i++) { for(int j = 0; j < 3; j++) { if(j == 1 || i == 1) { if(j == 1 && i == 1) matrix[i * 3 + j] = 5; else matrix[i * 3 + j] = -1; } else matrix[i * 3 + j] = 0; } } UserFilterCommand command = new UserFilterCommand(3, 3, LeadPointHelper.Create(1, 1), 1, 0, UserFilterCommandType.Sum, matrix); // Apply the high pass custom filter. command.Run(image); }
public void UserFilterConstructorExample(RasterImage image, Stream outStream) { // Prepare the command int[] matrix = new int[9]; // Initialize the array with factor used to apply the high pass filter. for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (j == 1 || i == 1) { if (j == 1 && i == 1) matrix[i * 3 + j] = 5; else matrix[i * 3 + j] = -1; } else matrix[i * 3 + j] = 0; } } UserFilterCommand command = new UserFilterCommand(3, 3, new LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix); // Apply the high pass custom filter. command.Run(image); // Save result image RasterCodecs codecs = new RasterCodecs(); codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24); image.Dispose(); }
Public Sub UserFilterConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream) ' Prepare the command Dim matrix As Integer() = New Integer(8){} ' Initialize the array with factor used to apply the high pass filter. For i As Integer = 0 To 2 For j As Integer = 0 To 2 If j = 1 OrElse i = 1 Then If j = 1 AndAlso i = 1 Then matrix(i * 3 + j) = 5 Else matrix(i * 3 + j) = -1 End If Else matrix(i * 3 + j) = 0 End If Next j Next i Dim command As UserFilterCommand = New UserFilterCommand(3, 3, New LeadPoint(1, 1), 1, 0, UserFilterCommandType.Sum, matrix) ' Apply the high pass custom filter. command.Run(image) ' Save result image Dim codecs As RasterCodecs = New RasterCodecs() codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24) image.Dispose() End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2